function transTime(str){
    var arr=str.split(':');
    return arr[0]*60*60+arr[1]*60+arr[2];
  }
function drawCount(obj,countTime,nowTime,txtcol,color){
    //总时间
    var count = this.transTime(countTime);
    //剩余时间
    var now = this.transTime(nowTime);
    var useTime = count-now;
    // 基于准备好的dom，初始化echarts实例
  let myChart = echarts.init(document.getElementById(obj))
  // 绘制图表
  myChart.setOption({
      title: [{
          text: nowTime,
          x: 'center',
          y:'center',
          textStyle: {
              color: txtcol,
              fontSize: 12,
              fontWeight:0
          }
      }],
      polar: {
          radius: ['80%', '100%'],
          center: ['50%', '50%'],
      },
            angleAxis: {
        max: 100,
        show: false,
    },
    radiusAxis: {
        type: 'category',
        show: true,
        axisLabel: {
            show: false,
        },
        axisLine: {
            show: false,

        },
        axisTick: {
            show: false
        },
    },
      series: [
          {
            name: '',
            type: 'bar',
            roundCap: true,
            barWidth: 60,
            showBackground: true,
            backgroundStyle: {
                color: '#363A42',
            },
            data: [parseInt(useTime/count*100)],
            coordinateSystem: 'polar',
            itemStyle: {
                normal: {
                    color: color
                }
            }
        }
      ]
  });
}
function drawPercent(obj,percent,txtcol,color){
    // 基于准备好的dom，初始化echarts实例
      let myChart = echarts.init(document.getElementById(obj))
      // 绘制图表
      myChart.setOption({
          title: [{
              text: percent,
              x: 'center',
              y:'center',
              textStyle: {
                  color: txtcol,
                  fontSize: 12,
                  fontWeight:0
              }
          }],
          polar: {
              radius: ['80%', '100%'],
              center: ['50%', '50%'],
          },
                angleAxis: {
            max: 100,
            show: false,
        },
        radiusAxis: {
            type: 'category',
            show: true,
            axisLabel: {
                show: false,
            },
            axisLine: {
                show: false,

            },
            axisTick: {
                show: false
            },
        },
          series: [
              {
                name: '',
                type: 'bar',
                roundCap: true,
                barWidth: 60,
                showBackground: true,
                backgroundStyle: {
                    color: '#363A42',
                },
                data: [parseInt(percent)],
                coordinateSystem: 'polar',
                itemStyle: {
                    normal: {
                        color: color
                    }
                }
            }
          ]
      });
  }

function drawStatic(per){
    let myChart = echarts.init(document.getElementById('chart2'));
    var myPer=(parseInt(per) / 3);
    if(myPer<=0){
      myPer=0.01;
    }else if(myPer>=1){
      myPer=0.99;
    }
    myChart.setOption({
        title: {
            text: '{a|'+per+'}\n{c|静态收益率}',
            x: 'center',
            y: 'center',
            textStyle: {
                rich:{
                    a: {
                        fontSize: 18,
                        color: '#9771FB'
                    },
                    c: {
                        fontSize: 8,
                        color: '#9771FB',
                        padding: [5,0]
                    }
                }
            }
        },
        series: [
            {
                type: 'gauge',
                radius: '100%',
                clockwise: false,
                startAngle: '90',
                endAngle: '-269.9999',
                splitNumber: 3,
                detail: {
                    offsetCenter: [0, -20],
                    formatter: ' '
                },
                pointer: {
                    show: false
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: [
                            [myPer, '#363a42'],
                            [1, '#9771FB']
                        ],
                        width: 8
                    }
                },
                axisTick: {
                    show: false
                },
                splitLine: {
                    show: true,
                    length: 8,
                    lineStyle: {
                        color: '#262320',
                        width: 8
                    }
                },
                axisLabel: {
                    show: false
                }
            }
        ]
          })
        }